//
//  GYService.h
//  LockManagement
//
//  Created by apple on 2018/7/30.
//  Copyright © 2018年 yunjiazhineng. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>



@class GYService;
@class GYCharacteristic;
@class GYPeriphreal;

/**
 发现服务上的特征时候调用

 @param characteristicArray 所有特征
 @param error <#error description#>
 */
typedef void(^blueManagerSearchCharacteristicBlock)(NSArray<GYCharacteristic *> *characteristicArray, NSError *error);

@interface GYService : NSObject

/** 服务名称 */
@property (nonatomic, strong, readonly) NSString *name;

/** 系统提供出来服务 */
@property (nonatomic, strong) CBService *service;

/** 所有服务 */
@property (nonatomic, strong) NSArray *includedServices;

/** 服务所在设备 */
@property (nonatomic, strong, readonly) GYPeriphreal *periphreal;

/** 服务唯一标示 */
@property (nonatomic,strong, readonly)CBUUID * UUID ;

/** 服务是否是开启状态 */
@property (nonatomic,assign)BOOL isOn ;

/** 服务是否是可用状态 */
@property (nonatomic,assign)BOOL isEnabled ;

/** 服务中所有的特征 */
@property(nonatomic, strong ,readonly) NSMutableArray<GYCharacteristic *> *characteristicArray;


/**
 初始化方法

 @param service 服务
 @return <#return value description#>
 */
- (instancetype)initWithService:(CBService *)service ;

/**
 初始化服务

 @param service 服务
 @param peripheral 该服务属于那个设备
 @return <#return value description#>
 */
- (instancetype)initWithService:(CBService *)service perpheral:(GYPeriphreal *)peripheral ;

/**
 查找服务中的特征

 @param characteristic <#characteristic description#>
 @return <#return value description#>
 */
- (GYCharacteristic *)searchCharacteristciWithCharacteristic:(CBCharacteristic *)characteristic ;

/**
 发现特征之后回调

 @param callBack <#callBack description#>
 */
- (void)discoverCharacteristicWithCallBack:(blueManagerSearchCharacteristicBlock)callBack;
- (void)discoverCharacteristicWithCharacteristicUUIDs:(NSArray<CBUUID *> *)uuidArray
                                             callback:(blueManagerSearchCharacteristicBlock)callback ;

/**
 初始manager连接的结果

 @param characteristics <#characteristics description#>
 @param error <#error description#>
 */
- (void)dealDiscoverCharacteristic:(NSArray *)characteristics error:(NSError *)error;
@end
